﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using NHibernate.Cfg;
namespace NCS_CS
{
    static class testNh
    {
        static ISession session;
        public static ISession getsession()
        {
            if (session != null)
            {
                if (session.IsOpen)
                {
                    return session;
                }
                else
                {
                    Configuration c = NCS.Class1.configuration;
                    ISessionFactory factory = c.BuildSessionFactory();
                    session = factory.OpenSession();
                    return session;
                }
            }
            else
            {
                Configuration c = NCS.Class1.configuration;
                ISessionFactory factory = c.BuildSessionFactory();
                session = factory.OpenSession();
                return session;
            }
        }
    }
}
